package com.notice.common;

import java.util.ArrayList;
import java.util.List;

public class LiveData<T> {
    private T value;
    private List<Observer<T>> observers = new ArrayList<>();

    public interface Observer<T> {
        void onChanged(T value);
    }

    public void observe(Observer<T> observer) {
        observers.add(observer);
    }

    public void setValue(T value) {
        this.value = value;
        notifyObservers();
    }

    private void notifyObservers() {
        for (Observer<T> observer : observers) {
            observer.onChanged(value);
        }
    }
} 